package dao;

import java.util.List;

import model.Aluno;

public class DAOAluno extends ModelDAO<Aluno>{
	public DAOAluno() {
        super(Aluno.class);
    }
	
	public void save(Aluno a){
		super.begin();
		super.save(a);
		super.commit();
	}
	
	public void update(Aluno a){
		super.begin();
		super.update(a);
		super.commit();
	}
	
	public Aluno search(int cod){
		super.begin();
		Aluno a = super.search(cod);
		super.commit();
		return a;
	}
	
	public List<Aluno> listar(){
		super.begin();
        List<Aluno> list = super.findAll();
        super.commit();
        return list;
    }
	
	public Aluno validarLogin(String usAluno, String senhaAluno){
		super.begin();
		Aluno aluno = new Aluno();
		String hql = "select a from Aluno a where a.matriculaAluno='" + usAluno + "' and a.senhaAluno='" + senhaAluno + "'";
		Aluno a = super.buscarObjeto(hql, aluno);
        super.commit();
        return a;
    }
	
	public void delete(Aluno a){
		super.begin();
		super.delete(a.getCodAluno());
		super.commit();
	}

}
